class Animal(object):
    def run(self):
        print('Animal is running...')

class Dog(Animal):
    # 可以改写run，但是不是强制性的
    def run(self):
        print('Dog is running...')

class Cat(Animal):
    def run(self):
        print('Cat is running...')

dog = Dog()
dog.run()

cat = Cat()
cat.run()


def run_twice(animal):
    animal.run()
    animal.run()

run_twice(Dog())
run_twice(Cat())

class A(object):
    # 成员方法必须要有self参数
    def run(self):
        print("A is run")

# python是动态语言，对于run_twice函数来说，传递的参数中，只要有run方法，那么就能运行。不一定必须是animal的子类
run_twice(A())

